package com.ulook.lookplanet.data.source;

import com.ulook.lookplanet.common.AppServer;
import com.ulook.lookplanet.data.model.TComment;
import com.ulook.lookplanet.ui.square.article.VArtCount;
import com.ulook.lookplanet.ui.square.article.VCommentInfo;
import com.ulook.lookplanet.util.net.AsynRequestUtil;
import com.ulook.lookplanet.util.net.RequestParams;
import com.ulook.lookplanet.util.net.ResponseCallback;

/**
 * 描述：
 *
 * @author L1998
 * @data 2021/4/21
 */
public class ArticleDataSource {

    /**
     * 获取图片
     */
    public void getPic(String artId, ResponseCallback callback){
        RequestParams params = new RequestParams();
        params.put("artid", artId);
        AsynRequestUtil.post(AppServer.ROOT_PATH + "/article/getArtPic", params, null, callback);
    }

    /**
     * 获取统计数据
     */
    public void getCount(String artId, ResponseCallback callback){
        RequestParams params = new RequestParams();
        params.put("artId", artId);
        AsynRequestUtil.post(AppServer.ROOT_PATH + "/article/getArtCount", params, VArtCount.class, callback);
    }

    /**
     * 评论
     */
    public void commentAction(TComment comment, ResponseCallback callback){
        RequestParams params = new RequestParams();
        params.put("artid", comment.getArtid());
        params.put("userid", comment.getUserid());
        params.put("content", comment.getContent());
        if(comment.getUpid() != null){
            params.put("upid", comment.getUpid());
            params.put("replay", comment.getReplyuser());
        }
        AsynRequestUtil.post(AppServer.ROOT_PATH + "/article/comment", params, VCommentInfo.class, callback);
    }

    /**
     * 获取评论数据
     */
    public void getComment(String artId, int itemNum, ResponseCallback callback){
        RequestParams params = new RequestParams();
        params.put("artid", artId);
        params.put("itemNum", itemNum);
        AsynRequestUtil.post(AppServer.ROOT_PATH + "/article/getComment", params, null, callback);
    }

}
